﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;
using CNav.App_Start;
using CNav.Common;
using Microsoft.Practices.Unity;

namespace CNav
{

    public class MvcApplication : HttpApplication
    {
        protected void Application_Start()
        {
            var log4NetPath = Server.MapPath("~/log4net.config");
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(log4NetPath));

            var unityContainer = BuildUnityContainer();

            Bootstrapper.Initialise(unityContainer);
            Business.Bootstrapper.Initialise(unityContainer);

            AutoMapping.Initialise();

            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
        }

        private static IUnityContainer BuildUnityContainer()
        {
            var container = new UnityContainer();
            return container;
        }
    }
}